<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="https://cdn.bootcdn.net/ajax/libs/react/17.0.1/umd/react.development.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/react-dom/17.0.1/umd/react-dom.development.min.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
    <script type="text/babel">
      const { Component, createRef, useRef } = React;
      class UseRef extends Component {
        myRef = createRef();
        show = () => {
          alert(this.myRef.current.value);
        };
        render() {
          return (
            <div>
              <input type="text" ref={this.myRef} />
              <button onClick={this.show}>点击提示数据</button>
            </div>
          );
        }
      }
      function UseRef1() {
        const myRef = useRef();
        function show() {
          alert(myRef.current.value);
        }
        return (
          <div>
            <input type="text" ref={myRef} />
            <button onClick={show}>点击提示数据</button>
          </div>
        );
      }
      let vdom = (
        <h1>
          <UseRef />
          <br />
          <UseRef1 />
        </h1>
      );
      ReactDOM.render(vdom, document.getElementById("root"));
    </script>
  </body>
</html>
